home *** CD-ROM | disk | FTP | other *** search
- /*
- GDInfo.c
- Gets various bits of useful information from the driver, if possible, or,
- failing that, from the GDevice record, and puts them into the user-supplied
- record. Under 1-bit QuickDraw it ignores the "device" argument.
-
- This routine gets all the information that can be had quickly without disturbing
- the screens. TimeVideo.c and TestClut.c get further information. I'd like to end
- up with a few low level subroutines, like this one, that just fill in the
- VideoCard structure, so that the demo programs would mainly just print out the
- information in an intelligible way.
- */
- #include <VideoToolbox.h>
- #include <GDInfo.h>
-
- OSErr GDInfo(GDHandle device,VideoCard *card)
- {
- OSErr error;
- GammaTbl *gamma;
- Boolean ok;
- short pageCount,j;
- Rect r;
- long quickDraw;
- ColorSpec cSpec;
-
- Gestalt(gestaltQuickdrawVersion,&quickDraw);
- if(quickDraw<gestalt8BitQD){
- sprintf(card->cardName,"%s","Original 1-bit QuickDraw");
- sprintf(card->driverName,"%s","Original 1-bit QuickDraw");
- card->depth[0].pixelSize=1;
- for(j=1;j<6;j++)card->depth[j].pixelSize=0;
- card->slot=0;
- CopyQuickDrawGlobals(); // make sure qd is valid.
- r=qd.screenBits.bounds;
- card->width=r.right-r.left;
- card->height=r.bottom-r.top;
- card->isGray=0;
- card->depth[0].colors=2;
- card->depth[0].framesPerClutUpdate=NAN;
- card->depth[0].framesPerClutUpdateHighPriority=NAN;
- card->depth[0].framesPerClutUpdateQuickly=NAN;
- card->depth[0].vblPerFrame=1.0;
- card->gdType=fixedType;
- card->mode=oneBitMode;
- card->m=card->mode&7;
- card->dacSize=1;
- card->dacMask=((1<<card->dacSize)-1)<<(16 - card->dacSize);
- return 0;
- }
- sprintf(card->cardName,"%s",GDCardName(device));
- if(GDVersion(device)==0)sprintf(card->driverName,"%#s",GDName(device));
- else sprintf(card->driverName,"%#s version %d",GDName(device),GDVersion(device));
- for(j=0;j<6;j++){
- if(NewPaletteManager()){
- ok=HasDepth(device,1<<j,0,0);
- }else{
- error=GDGetPageCnt(device,0x80+j,&pageCount);
- ok=(!error && pageCount>0);
- }
- if(ok){
- card->depth[j].pixelSize=1<<j;
- GDGetPageCnt(device,0x80+j,&card->depth[j].pages);
- }else{
- card->depth[j].pixelSize=0;
- card->depth[j].pages=0;
- }
- }
- card->slot=GetDeviceSlot(device);
- r=(**(**device).gdPMap).bounds;
- card->width=r.right-r.left;
- card->height=r.bottom-r.top;
- // Quadra 900 built-in video gives misleading answer on portrait? monitor, always gray.
- // error=GDGetGray(device,&card->isGray);
- // if(error);
- card->isGray=!TestDeviceAttribute(device,gdDevType);
- error=GDGetMode(device,&card->mode,NULL,NULL);
- if(error)card->mode=(**device).gdMode;
- card->m=card->mode&7;
- card->depth[card->m].colors=GDClutSize(device);
- card->gdType=(*device)->gdType;
- if(card->gdType!=fixedType) switch(card->mode){
- default:
- case oneBitMode:
- case twoBitMode:
- case fourBitMode:
- case eightBitMode:
- card->gdType=clutType;
- break;
- case sixteenBitMode:
- case thirtyTwoBitMode:
- card->gdType=directType;
- break;
- }
- error=GDGetGamma(device,&gamma); // Takes 200 µs.
- if(error)card->dacSize=8;
- else card->dacSize=gamma->gDataWidth;
- card->dacMask=((1<<card->dacSize)-1)<<(16 - card->dacSize);
- card->setEntriesQuickly=(GetCardType(device)!=0);
- card->gdGetEntries=(0==GDGetEntries(device,0,0,&cSpec));
- card->basicTest=1;
- return 0;
- }
-
- OSErr GDTime(GDHandle device,VideoCard *card)
- {
- OSErr error;
- short colors=0,m=card->m;
- double frames,s,missingFrames,frameRate;
- long cpu,quickDraw;
-
- printf("%d-bit pixels: timing CopyBits . . . \r",card->depth[m].pixelSize);
- card->depth[m].movieRate=GDMovieRate(device,0);
- printf("%d-bit pixels: timing CopyBitsQuickly . . . \r",card->depth[m].pixelSize);
- card->depth[m].movieRateQuickly=GDMovieRate(device,1);
-
- Gestalt(gestaltQuickdrawVersion,&quickDraw);
- Gestalt(gestaltProcessorType,&cpu);
- if(quickDraw>=gestalt8BitQD){
- printf("%d-bit pixels: timing GDSetEntries . . . \r",card->depth[m].pixelSize);
- error=GDTimeClut(device,GDSetEntries,colors,&s,&frames,&missingFrames,&frameRate);
- if(error)frameRate=GDFrameRate(device);
- card->depth[m].frameRate=frameRate;
- card->depth[m].vblPerFrame=GDVBLRate(device)/frameRate;
- card->depth[m].framesPerClutUpdate=frames;
- card->depth[m].missingFramesPerClutUpdate=missingFrames;
- }else{
- card->depth[m].frameRate=GDFrameRate(NULL);
- card->depth[m].vblPerFrame=1.0;
- card->depth[m].framesPerClutUpdate=NAN;
- card->depth[m].missingFramesPerClutUpdate=NAN;
- }
- if(quickDraw>=gestalt8BitQD){
- printf("%d-bit pixels: timing GDSetEntriesByTypeHighPriority . . . \r",card->depth[m].pixelSize);
- error=GDTimeClut(device,GDSetEntriesByTypeHighPriority,colors,&s,&frames,&missingFrames,&frameRate);
- card->depth[m].framesPerClutUpdateHighPriority=frames;
- card->depth[m].missingFramesPerClutUpdateHighPriority=missingFrames;
- }else{
- card->depth[m].framesPerClutUpdateHighPriority=NAN;
- card->depth[m].missingFramesPerClutUpdateHighPriority=NAN;
- }
- if(quickDraw>=gestalt8BitQD && cpu>=gestalt68020 && GetCardType(device)){
- printf("%d-bit pixels: timing SetEntriesQuickly . . . \r",card->depth[m].pixelSize);
- error=GDTimeClut(device,SetEntriesQuickly,colors,&s,&frames,&missingFrames,&frameRate);
- card->depth[m].framesPerClutUpdateQuickly=frames;
- card->depth[m].missingFramesPerClutUpdateQuickly=missingFrames;
- }else{
- card->depth[m].framesPerClutUpdateQuickly=NAN;
- card->depth[m].missingFramesPerClutUpdateQuickly=NAN;
- }
- printf(" \r");
- card->timeTest=1;
- }